<%@ page language="java" import="java.util.*,com.hs.core.cache.*,com.hs.wdss.model.*,com.hs.auth.*,com.hs.auth.model.*" pageEncoding="utf-8"%>
 <%
  String disname = (String)request.getAttribute("disname");
  String discode = (String)request.getAttribute("discode");
  String dstype = (String)request.getAttribute("dstype");
  String state = (String)request.getAttribute("state");
  String orderName = (String)request.getAttribute("orderName");
  String orderNum = (String)request.getAttribute("orderNum"); 
  
  String pageStr = (String)request.getAttribute("pagestr");
  List datalist = (List)request.getAttribute("datalist");
  String pagenum = (String)request.getAttribute("pagenum");
  String pagecount = (String)request.getAttribute("pagecount");
  if(null == state || "".equals(state)){
  	state = "0";
  }
  int pagenumInt = Integer.parseInt(pagenum);
  int pagecountInt = Integer.parseInt(pagecount);
  
  //取登陆用户权限
HsAccount accInfo = (HsAccount)request.getSession().getAttribute(AUTHConstant.USERINSESSION);
Map authMap = (Map)request.getSession().getAttribute("USERPOWER_"+accInfo.getId());
if(authMap == null)
	authMap = new HashMap();
boolean isadmin = "system".equals(accInfo==null?"":accInfo.getLoginid());
boolean role1 = (authMap.get("WDSS_ROLE01")!=null);
boolean role2 = (authMap.get("WDSS_ROLE02")!=null); 
boolean role3 = (authMap.get("WDSS_ROLE03")!=null);
boolean role4 = (authMap.get("WDSS_ROLE04")!=null); 
  %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@ include file="../../include.jsp"%>  
<script language="javascript" type="text/javascript" src="<%=path %>/thirtpart/My97DatePicker/WdatePicker.js"></script>
<script src='<%=basePath%>dwr/interface/auditdwr.js'></script> 
<script src='<%=basePath%>dwr/interface/dataProhelper.js'></script> 

<script language="javascript" type="text/javascript">
function dataPro(id){
	window.location.href="<%=basePath%>produce/dataPro.do?wdssid="+id;
}
//增加医案
function addDis(id){
	window.location.href="<%=basePath%>produce/addDis.do";
}
function viewDetail(id){
	//var pageURL = "<%=basePath %>audit/auditlistFrame.do?id=" + id;
	//openwindow(pageURL,'1000','800','数据浏览'); 

}
//题录信息
 function magaInfo(id)
{
	var pageURL = "<%=basePath %>data/magainfo.do?id=" + id;
	openwindow(pageURL,'800','600','题录信息'); 
}
//提交审核
function submitAudit(id){
     if(confirm("确定要提交审核吗？"))
	 	dataProhelper.submitAudit(id,callback4submitAudit);
}
function callback4submitAudit(){ 
    alert("成功提交审核!");
	document.searchform.submit();
}
 //审核
 function audit(id,state)
{	
	auditdwr.audit(id,state,callback4audit)
}

 function callback4audit(message){
        alert("审核完成"); 
 	    document.searchform.submit();
 }
 //退回
 function auditBack(id,state)
{	
if(confirm("确定要退回吗？"))
	auditdwr.audit(id,state,callback4auditback)
}

 function callback4auditback(message){
        alert("退回成功"); 
 	    document.searchform.submit();
 }
 //查看加工结果
 function viewDetail(id){
	var pageURL = "<%=basePath %>produce/proResultFrame.do?wdssid=" + id;
	openwindow(pageURL,'1000','800',''); 
}
function deleteMR(){
	var disid = getRadioValue("disinfoid");
	if(typeof(disid) == 'undefined'){
		alert('请先选择要删除的医案!');
	    return;
	} 
	var wdssid = document.getElementById("rid_"+disid).value;
	if(confirm('您确认要删除该医案吗?')){ 
		dataProhelper.deleteMr(disid,wdssid,callback4delete);
	}

}
function callback4delete(data){
	alert('删除成功!');
    searchform.submit();
}
</script>
</head>
<body>
<form name="searchform" action="<%=basePath %>produce/dataprolist.do?1=1" method=post>
    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="sear">
      <tr>
       <td width="10%"> 
          医案来源： 
        </td>
        <td width="10%">
          <select name="dstype" style="width:98%">
          <option value="0" <%if("0".equals(dstype)){out.println( "selected");} %>>全部</option>
          <option value="1" <%if("1".equals(dstype)){out.println( "selected");} %>>古籍</option>
          <option value="2" <%if("2".equals(dstype)){out.println( "selected");} %>>期刊</option>
          </select>
        </td> 
         <td width="10%">
          医案编号：
        </td> 
         <td width="10%">
          <input name="discode" type="text" value="<%=discode==null?"":discode %>"/>
        </td> 
        <td width="10%">
          病名：
        </td>
        <td width="10%">
          <input name="disname" type="text" value="<%=disname==null?"":disname %>"/>
        </td>  
        <td width="10%">
          加工状态：
        </td>
         <td width="10%">
         <select id="state" name="state" style="width:100%">
           <%if(isadmin || role1){ %>
            <option value="all" <%if("all".equals(state)){out.println(" selected");}%> >全部数据</option>
            
            <%} %>
         	<option value="99" <%if("99".equals(state)){out.println(" selected");}%> >全部我加工的</option>
         	<option value="0"  <%if("0".equals(state)){out.println(" selected");} %>>待加工</option>
         	<option value="1" <%if("1".equals(state)){out.println(" selected");} %>>加工中</option>
         	<option value="2" <%if("2".equals(state)){out.println(" selected");} %>>待审核</option>
         	<option value="3" <%if("3".equals(state)){out.println(" selected");} %>>加工完成</option>
         	<option value="4" <%if("4".equals(state)){out.println(" selected");} %>>审核不合格</option>
          	</select> 
         </td>
         <td width="20%" align="center">
            <input   type="submit" value=" 查 询 " class="butt"/>&nbsp;&nbsp;&nbsp;&nbsp;
            <%if(role1 || isadmin){ %><input   type="button" value=" 删 除 " onclick="deleteMR();"class="butt"/><%} %>
        </td>
          
        </tr>
    </table>
</form>
	<table border="0" cellspacing="0" cellpadding="0" style="width:100%" class="list">
      <tr>
        <th width="5%">序号</th> 
        
        <th width="15%"><a href="javaScript:orderPage('dstype','<%=OrderTool.getOrderNum("dstype",orderName,orderNum)%>');">医案来源&nbsp;&nbsp;<%=OrderTool.getOrderImage(basePath,OrderTool.getOrderNum("dstype",orderName,orderNum))%></a></th>
        <th width="10%">作者</th>
         <th width="7%">医案编号</th>
        <th width="10%">病名</th>
        <th width="5%">医案类别</th>
        <th width="5%">加工人员</th>
        <th width="8%"><a href="javaScript:orderPage('state','<%=OrderTool.getOrderNum("state",orderName,orderNum)%>');">状态&nbsp;&nbsp;<%=OrderTool.getOrderImage(basePath,OrderTool.getOrderNum("state",orderName,orderNum))%></a></th>
        <th width="5%">开始加工</th>  
        <th width="5%">提交审核</th> 
        <th width="5%">查看</th> 
        <th width="5%">合格</th> 
        <th width="5%">不合格</th> 
        <th width="5%">退回</th> 
      </tr>
      
      <% if(null != datalist && datalist.size()>0){
      		for(int i =0;i<datalist.size();i++){
      			Map dm = (Map)datalist.get(i);
       %>
      <tr>
        <td align="center"><input type="radio" value="<%=dm.get("id")%>" id="disinfoid" name="disinfoid"/><%= (pagecountInt*(pagenumInt-1))+i+1 %></td> 
        <td><a href="javaScript:magaInfo('<%=dm.get("dsid")%>');">
        <input type="hidden" name="rid_<%=dm.get("id")%>" id="rid_<%=dm.get("id")%>" value="<%=dm.get("dsid")%>"/>
        <%=dm.get("bookname") %></a>
        </td>
        <td><%=StringUtilTool.NULL2Blank(dm.get("author")+"")%></td>
        <td><%=StringUtilTool.NULL2Blank(dm.get("discode")+"") %></td>
         <td><%=StringUtilTool.NULL2Blank(dm.get("disname")+"") %></td>
        <td><%=StringUtilTool.NULL2Blank(dm.get("dstype")+"") %></td>
        <td><%=StringUtilTool.NULL2Blank(dm.get("username")+"")%></td>
        <td><font color=red><strong>
                    <%=DictCacheUtil.getInst().selectStr4Display(dm.get("state")+"","15") %></strong></font></td>
        <td><%if("1".equals(dm.get("state"))||"0".equals(dm.get("state"))||"4".equals(dm.get("state"))){ %><input type="button" value="进入加工" onclick="dataPro('<%=dm.get("id")%>');" class="butt"/><%}%></td>
        <td><%if("1".equals(dm.get("state"))||"4".equals(dm.get("state"))){ %><input type="button" value="提交审核" onclick="submitAudit('<%=dm.get("id")%>');" class="butt"/><%}%></td>
        <td><input type="button" value="查看" onclick="viewDetail('<%=dm.get("id")%>');" class="butt"/></td>
        <td><%if(("2".equals(dm.get("state"))) && (role4 || role1|| isadmin)){ %><input type="button" value="合格" onclick="audit('<%=dm.get("id")%>','3');" class="butt"/><%}%></td>
        <td><%if(("2".equals(dm.get("state"))) && (role4 || role1|| isadmin)){ %><input type="button" value="不合格" onclick="audit('<%=dm.get("id")%>','4');" class="butt"/><%}%></td>
        <td><%if((!"0".equals(dm.get("state")))&&(!"1".equals(dm.get("state"))) && (role4 || role1|| isadmin)){ %><input type="button" value="退回" onclick="auditBack('<%=dm.get("id")%>','2');" class="butt"/><%}%></td>
       </tr>
      
      <%}}else{ %>
      <tr>
        <td align="center" colspan="14"><font color="red">没有数据</font></td>
      </tr>
      <%} %>
      <tr>
	          <td colspan=14 align="right">
	          <%=pageStr  %>
	          </td>
          </tr>
    </table> 
</body>
</html>

